class Solution {//leetcode47——全排列
private:
    void _dfs(vector<int>&nums){
        int n=nums.size();
        if(path.size()==n){
            ret.push_back(path);
            return;
        }
        for(int i=0;i<n;i++){
            if(check[i]==false&&(i==0||nums[i]!=nums[i-1]||check[i-1]==true)){
                path.push_back(nums[i]);
                check[i]=true;
                _dfs(nums);
                path.pop_back();
                check[i]=false;
            }
        }
    }
public:
    vector<vector<int>> permuteUnique(vector<int>& nums) {
        sort(nums.begin(),nums.end());
        _dfs(nums);
        return ret;
    }
private:
    vector<vector<int>> ret;
    bool check[8]={0};
    vector<int> path;
};